package com.sky.mapper.user;

import com.github.pagehelper.Page;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.pojo.Orders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;

@Mapper
public interface UserOrderMapper {
    void insert(Orders orders);

    @Select(("select * from orders where number = #{orderNum}"))
    Orders getByOrderNum(String orderNum);

    @Update("update orders set pay_status=#{payStatus},status=#{status},checkout_time=#{checkoutTime} where number=#{number}")
    void updatePaySuccess(Orders orders);

    @Select("select * from orders where status = #{status} and order_time < #{orderTime}")
    List<Orders> queryNeedCheckStatusOrOrders(Integer status, Date orderTime);

    @Update("update orders set status = #{status} where number = #{number}")
    void updateStatus(Integer status, String number);

    Page<Orders> historyOrders(OrdersPageQueryDTO pageQueryDTO);

    @Select(("select * from orders where id = #{id}"))
    Orders getByOrderId(Long id);

//    @Update("update orders set pay_status=#{payStatus},cancel_reason=#{cancelReason},cancel_time=#{cancelTime},status=#{status} where id=#{id}")
    void setStatus(Orders orders);
}
